/*
 * @Description:
 * @Author:
 * @Date: 2024-10-26 09:52:08
 * @LastEditTime: 2024-10-26 13:36:16
 * @LastEditors: XXX
 */
import { state } from './state'
import { mutations } from './mutations'
import { actions } from './actions'

import type { CommitOptions, DispatchOptions, Module, Store as VuexStore } from 'vuex'
import type { AppState } from './state'
import type { RootState } from "@/store";
import type { Mutations } from './mutations';
import type { Actions } from './actions';

export const store: Module<AppState, RootState> = {
  state,
  mutations,
  actions
}

export type { AppState }
export type AppStore<S = AppState> = Omit<VuexStore<S>, 'getters' | 'commit' | 'dispatch'>
  & {
    commit<K extends keyof Mutations, P extends Parameters<Mutations[K]>[1]> (
      key: K,
      payload: P,
      options?: CommitOptions
    ): ReturnType<Mutations[K]>
  } & {
    dispatch<K extends keyof Actions> (
      key: K,
      payload: Parameters<Actions[K]>[1],
      options?: DispatchOptions
    ): ReturnType<Actions[K]>
  }
